package cn.dmp.beans

class RichString(val value: String) {

    def toIntPlus: Int = {
        try {
            value.toInt
        } catch {
            case _: Exception => 0
        }
    }

    def toDoublePlus: Double = {
        try {
            value.toDouble
        } catch {
            case _: Exception => 0
        }
    }
}

object RichString {

    /**
      * 隐式方法
      */
    implicit def str2RichString(v: String): RichString = new RichString(v)

}
